package com.xxg.renrenorder.dao;

import com.xxg.renrencommon.domain.bean.UserCartInfo;
import org.bson.Document;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

import static org.springframework.data.mongodb.core.query.Criteria.where;

/**
 * 用户购物车DAO
 *
 * @author xxg
 * @date 2020/11/13
 */
@Repository
public class UserCartInfoDao {
    private final MongoTemplate mongoTemplate;

    public UserCartInfoDao(MongoTemplate mongoTemplate) {
        this.mongoTemplate = mongoTemplate;
    }


    public void removeProductFromCart(int userId, List<String> userCartIds) {
        Query query = new Query(where("userId").is(userId).and("_id").in(userCartIds));
        mongoTemplate.remove(query, UserCartInfo.class);
    }
}
